What is Constant,Variable and Datatype in C ?

In this article we will learn constant,variable and datatype of C in detail so if you any doubt in this topic than stay with this article.


What is Constant,Variable and Datatype in C
What is Constant,Variable and Datatype in C ?

Upon Completing this article,you will be able to:

  • Know the Character Set, C Token and Keywords.
  • Describe Constant and Variable.
  • Identifying the various C data types.  

Character Set in C:-

The Character that can be used to form words,number,and expression depend upon the computer on which the program is run.The Character Set in C are grouped into the following categories:
  1. Letters
  2. Digits
  3. Specials Character
  4. White Space  
1.Letter:-
                  Uppercase          A..........Z
                  Lowercase         a............z

2.Digits:- 
                        0,1,2,3,4....................,9 

3.Special Character:-
                                    ( , ) ----->comma
                                    ( . )------>period
                                    ( " )------>quotation mark
                                    ( ? )------->question mark
                                    ( ! )-------->exclamation mark etc
4.White Space:-
                           Blank Space
                           Horizontal tab
                           Carriage return
                           New line
                           Form feed

Tokens in C:-

In a passage of text, individual words and punctuation marks are called tokens.Similarly in a C program the smallest individual units of program are know as C tokens.C has six types of tokens as

  1.  Keyword
  2. Identifiers
  3. Constant
  4. Strings
  5. Specials Symbols
  6. Operators

Keywords in C:-

Every C words is classified as either a keyword or an identifier.Keyword are those words which meaning has been fixed and is known by its compiler and we can't be change meaning of keyword.if we try to do so an error message will occur.

There are 32 Keywords are available in C-language
 
1.auto                      9.double                17.int                     24.struct
2.break                   10.else                   18.long                  25.switch
3.case                     11.enum                19.register             26.typedef
4.char                     12.extern               20.return                27.union
5.continue              13.float                   21.short                 29.unsigned
6.const                   14.for                      22.signed              30.void
7.default                 15.goto                   23.sizeof               31.volatile
8.do                        16.if                        24.static                32.while

Indentifiers in C:-

An identifiers refer to the names of the variables,function and array.These are user defined names and consist of sequence of letters and digits with a letter as the first character. 

Both uppercase and lowercase letters are permitted,although lowercase letters commonly used.The underscore character is also permitted in identifiers.It is usually used as link between two words in long identifiers.

Rules For Identifiers:-

  1. First character must be an alphabet(or underscore).
  2. Must consist of only letters,digits or underscore.
  3. Only first 31 character are significant.
  4. Cannot use a keyword.
  5. Must not contain white space.

Constants in C:-

Constants in C language refer to fixed values that do not change during the execution of a program.C support several types of constants as illustrated in fig

  • If you want to learn about Constants of C in details than tap on above image and goto next article where are constants are define in details.
  • String,Specials Symbols and operator are discussed as and when they are encountered.

Variables in C:-

A variable is data name that may be used  to store data value. Unlike constant that remain unchanged during the execution of a program.a variable may take different value at different  times during execution.

A variables name can be chosen by the programmer in a meaningful way so as to reflect its function or nature in the program.Some example of such names are :average,height,total,count etc.

Rules for Variable:

  1.   They must begin with a letter.Some system permit underscore as the first character.
  2.   ANSI standard recognizes a length of 31 character. 
  3.   Uppercase and lowercase are significant.
  4.   It should not a keyword,
  5.   White space is not allowed. 

Data Type:-

C language rich in data type,Storage representation and machine instruction to handle constants differ from machine to machine. The variety of data types available allow the programmer to select the appropriate to the need of the application as well as the machine.

ANSI C support three classes of data type:

  1. Primary(or fundamental) data type
  2. Derived data type
  3. User defined data type

The Primary Data type:-

The primary data type are also know as primitive or fundamentals data type of C language.All C compiler support five fundamental data type,namely integer(int),character(char),floating point(float),double precision floating point(double) and void.



  • If you want to learnt about primary data type in details than click on above image and goto next article where primary data type define in details with example.

  • The user defined data type are defined in the next section while derived data type such as array,function,structure and pointer are discussed as and when they are encountered.

Conclusion:-

In this article we learnt about,Character Set in C,Token in C,Keyword,Variable,Identifiers,Contant,Datatype,in details if you have any doubt regarding this article then please comment below I will try to resolve your doubt as soon as possible.

Post a Comment (0)
Previous Post Next Post